<template>
    <view class="user_container">
        <view class="user_top_block">
            <image class="userinfo_head3_bg" mode="aspectFill"></image>
            <view class="zhezhao"></view>
            <!--  src='../../static/mapItem.png' -->
            <view class="user_top">
                <image class="user_icon" :src="loginUser.headimgurl?loginUser.headimgurl:'../../static/logo.png'" mode="aspectFill"></image>
                <view class="user_info">
                    <text class="user_name">{{loginUser.nickname}}</text>
                    <view class="user_id">
                        <text class="user_id_text">ID:{{loginUser.openid}}</text>
                        <text class="copy_text" @click="copyTBL(loginUser.openid)">复制</text>
                    </view>
                </view>
            </view>
        </view>
        <view class="other_order_block">
            <view class="other_order_list" v-for="(item,index) in orderList">
                <view class="other_order_item" @tap="tolinkUrlFun(item.url)" v-if="item.type!='tel'">
                    <view class="other_order_item_left">
                        <image mode="aspectFit" class="other_order_item_icon" :src="item.icon"></image>
                        <view class="">{{item.title}}</view>
                    </view>
                    <image class="jiantou" src="../../static/jiantou.png"></image>
                </view>
                <view class="other_order_item" @tap="calling(item.text)" v-else>
                    <view class="other_order_item_left">
                        <image mode="aspectFit" class="other_order_item_icon" :src="item.icon"></image>
                        <view class="">{{item.title}} : {{item.text}}</view>
                    </view>
                    <image class="jiantou" src="../../static/jiantou.png"></image>
                </view>
            </view>
        </view>
        <view class="bottom_logo_block">
            <text class="logo_name">卡卡充电</text>
            <text class="logo_slogan">让您的生活持续充电</text>
            <text class="logo_version">V 1.0.0</text>
        </view>
    </view>
</template>

<script>

export default {
  data() {
    return {
      setting: null,
      params:{},
      loginUser:getApp().globalData.loginUser,
      orderList:[
          {title:'我的订单',icon:'../../static/dingdan.png',url:'order'},
          // {title:'故障报修',icon:'../../static/weixiu.png',url:'form'},
          {title:'客服电话',type:'tel',text:'4009661039',icon:'../../static/kefu.png'}
      ]
    };
  },

  components: {},
  props: {},

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let that = this;
    // uni.setNavigationBarColor({
    //   frontColor: '#ffffff',
    //   backgroundColor: '#59bfba'
    // });
    // that.getData(that.params);
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {},

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {},

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {},

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {},

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    this.getData(this.params);
    uni.showNavigationBarLoading();
    uni.hideNavigationBarLoading(); //完成停止加载

    uni.stopPullDownRefresh(); //停止下拉刷新
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  },
  methods: {
    copyTBL: function (value) {
      var that = this;
      console.log("====copyTBL====", value);
      uni.setClipboardData({
        data: value,
        success: function (res) {
          uni.getClipboardData({
            success: function (res) {
              uni.showToast({
                title: '复制成功',
                icon: 'success',
                duration: 2000
              });
            }
          });
        }
      });
    },
    calling: function (phoneNumber) {
      console.log('==phoneNumber===',phoneNumber)
      uni.makePhoneCall({
        phoneNumber: phoneNumber,
        success: function () {
          console.log("拨打电话成功！")
        },
        fail: function () {
          console.log("拨打电话失败！")
        }
      })
    },
    tolinkUrlFun:function(url){
        if(url){
            uni.navigateTo({
              url: '/pages/'+url+'/index'
            });
        }
    },
    /* 获取数据 */
    getData: function (param) {
      var customIndex = getApp().globalData.AddClientUrl("/more_product_list.html", param);
      getApp().globalData.showToastLoading('loading', true);
      var that = this;
      uni.request({
        url: customIndex.url,
        header: getApp().globalData.header,
        success: function (res) {
          uni.hideLoading();
          console.log(res.data);
          uni.hideLoading();
        },
        fail: function (res) {
          console.log("fail");
          uni.hideLoading();
          getApp().globalData.loadFail();
        }
      });
    },
    setData: function (obj) {
      let that = this;
      let keys = [];
      let val, data;
      Object.keys(obj).forEach(function (key) {
        keys = key.split('.');
        val = obj[key];
        data = that.$data;
        keys.forEach(function (key2, index) {
          if (index + 1 == keys.length) {
            that.$set(data, key2, val);
          } else {
            if (!data[key2]) {
              that.$set(data, key2, {});
            }
          }

          data = data[key2];
        });
      });
    }
  }
};
</script>
<style>
@import "./index.css";
</style>